package com.rg.servlet;

import com.rg.model.GoodsModel;
import com.rg.dao.Goodsdao;
import com.rg.service.GoodsService;
import com.rg.service.GoodsTypeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/GoodsRecommandServlet")
public class GoodsRecommandServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        GoodsService goodsService=new GoodsService();
        //获取首页轮播图区域的商品
        List<GoodsModel> goodsScrolllist=goodsService.selectScrollGoods();
        req.setAttribute("scrollGoods",goodsScrolllist);
        Goodsdao goodsdao=new Goodsdao();
        //获取首页推荐商品
        List<GoodsModel>IndexGoodsList=goodsService.selectIndexRecommendGoods();
        req.setAttribute("IndexGoodsList",IndexGoodsList);
        req.getRequestDispatcher("index.jsp").forward(req,resp);

    }
}
